<template>
  <Card class="xzqy-page" style="height:900px">
    <div style="width:350px;margin:150px auto">
    <Row type="flex" align="middle" style="width: 40px">
      <Col span="6" style="margin-top:30px;">流程节点:</Col>
      <Col span="25">
      <Input v-model="nodeName" placeholder="请输入" style="width: 200px"></Input>
      </Col>
    </Row>
    <Row type="flex" align="middle">
      <Col span="6" style="margin-top:30px;">角色:</Col>
      <Col span="18">
      <Input v-model="roleName" placeholder="请输入" style="width: 200px"></Input>
      </Col>
    </Row>
    <Row type="flex" align="middle">
      <Col span="6" style="margin-top:30px;">是否有效:</Col>
      <Col span="25">
      <Select v-model="status" style="width:200px"  >
        <Option v-for="item in statusDatas" :value="item.value" :key="item.value">{{ item.label }}</Option>
      </Select>
      </Col>
    </Row>
    <Row type="flex" align="middle" style="margin-top:20px">
      <Col span="9"></Col>
      <Col span="14">
      <Button type="primary" @click="subFlowNode" size="small">提交</Button>
      </Col>
    </Row>
  </div>
  </Card>
</template>
<script>

export default {
  data () {
    return {
      nodeName: null,
      roleName: null,
      id: null,
      status: 0,
      statusDatas: [
        {
          label: '有效',
          value: 0
        },
        {
          label: '无效',
          value: 1
        }
      ]
    }
  },
  created () {
    this.$ajax = this.$util.ajax()
    this.initCodeRoles()
  },
  methods: {
    subFlowNode () {
      var params = {}
      params.id = this.id
      params.status = this.status
      this.$ajax.post(this.$appContext.marvels_core_approve + 'approve/case_node_role/service/merge', params).then(re => {
        if (re.data.code === 'success') {
          this.$Message.success('操作成功!')
          this.$router.push({
            name: 'case_node_role'
          })
        } else {
          this.$Message.warning(re.data.data)
        }
      }).catch(er => {
        this.$Message.warning('操作失败')
      })
    },
    // 加载流程节点权限
    initCodeRoles () {
      var params = {}
      params.id = this.$route.params.id
      this.$ajax.post(this.$appContext.marvels_core_approve + 'approve/case_node_role/service/getid', params).then(re => {
        if (re.data.code === 'success') {
          this.nodeName = re.data.data.nodeName
          this.roleName = re.data.data.roleName
          this.status = re.data.data.status
          this.id = re.data.data.id
        } else {
        }
      }).catch(er => {
      })
    }

  }
}
</script>

<style lang="less">
  .xzqy-page {
    /*@media only screen and (min-width:1366px){
      .bottom-btn button:nth-of-type(1){
        margin-right:70px;
      }
    }
    @media only screen and (min-width:1200px){
      .bottom-btn button:nth-of-type(1){
        margin-right:40px;
      }
    }*/
  }
</style>
